package com.study.d3_stringbuilder;

public class Test {
    public static void main(String[] args) {
        //学会StringBuilder，理解其好处
        StringBuilder sb = new StringBuilder();
        StringBuilder sb2 = new StringBuilder("黑马");
        System.out.println(sb);
        System.out.println(sb2);
        sb.append("你好").append("哈哈");
        System.out.println(sb);
        sb.reverse();
        System.out.println(sb);
        System.out.println(sb.length());
        //把StringBuilder对象转换成String对象
        //StringBuilder是拼接字符串的手段
        //String才是开发的目的

        //对于字符串频繁的拼接、修改工作，建议用StringBuilder，效率更高
        String string = sb.toString();
        System.out.println(string);
        //StringBuffer和StringBuilder区别：StringBuilder线程不安全，StringBuffer线程安全
    }
}
